package com.cbw.blog.utils;

import com.cbw.blog.entity.Statistic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Component;

import javax.mail.internet.MailDateFormat;
@Component
public class MailUtils {
    @Autowired
    public JavaMailSenderImpl javaMailSender;
    @Value("${spring.mail.username}")
    public String mailFrom;


    public  void sendSimpleEmail(String mailto,String title,String text){
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(mailFrom);
        message.setTo(mailto);
        message.setSubject(title);
        message.setText(text);
        javaMailSender.send(message);
    }
}
